//
//  TMTeacherDescribeCell.m
//  国学商家管理
//
//  Created by Tao Li on 2018/7/5.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMTeacherDescribeCell.h"
#import "SPToolSet.h"
#import "TMShopCourseModel.h"
@implementation TMTeacherDescribeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.listArray = [NSMutableArray array];
}

- (void)setModel:(TMShopTeacherModel *)model{
    _model = model;
    self.detailLabel.text = model.abstract;
    [self displaySC];
}
//- (void)setCheckSC:(UIScrollView *)checkSC{
//    _checkSC = checkSC;
//    [self.checkSC setContentSize:CGSizeMake(123*8 +6, 0)];
//    self.checkSC.pagingEnabled = YES;
//    for (int i = 0; i < 8; i ++) {
//        UIImageView *itemView = [[UIImageView alloc]initWithFrame:CGRectMake(11 +(109 +14) *i, 0, 109, self.checkSC.bounds.size.height)];
//        itemView.tag = 100+i;
//        [self.checkSC addSubview:itemView];
//        //        itemView.image = [UIImage imageNamed:@"圆角矩形2"];
//        itemView.image = [SPToolSet boxblurImage:[UIImage imageNamed:@"tu"] withBlurNumber:0.2];
//        itemView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
//        UILabel *label = [[UILabel alloc]init];
//        [itemView addSubview:label];
//        BOOL hasVideo = i%2;
//        if (hasVideo == NO) {
//            [label mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.centerX.equalTo(itemView.mas_centerX);
//                make.centerY.equalTo(itemView.mas_centerY);
//                make.left.equalTo(itemView.mas_left).offset(5);
//                make.right.equalTo(itemView.mas_right).offset(5);
//            }];
//        }else{
//            [label mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.centerX.equalTo(itemView.mas_centerX);
//                make.top.equalTo(itemView.mas_top).offset(11); make.left.equalTo(itemView.mas_left).offset(5);
//                make.right.equalTo(itemView.mas_right).offset(5);
//            }];
//            UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//            [itemView addSubview:addBtn];
//            [addBtn setImage:[UIImage imageNamed:@"组4"] forState:UIControlStateNormal];
//            [addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.centerX.equalTo(itemView.mas_centerX);
//                make.top.equalTo(label.mas_bottom).offset(2);
//                make.size.mas_equalTo(CGSizeMake(21, 21));
//
//            }];
//        }
//        label.text = @"调用商家认证时后台传的图";
//        label.textColor = [UIColor hx_colorWithHexRGBAString:@"FFFFFF"];
//        label.font = [UIFont systemFontOfSize:10];
//        label.numberOfLines = 2;
//    }
//}
- (void)displaySC{
    [self.listArray addObjectsFromArray:self.model.teacher_certificate];
    [self.listArray addObjectsFromArray:self.model.skill_qualification];
    [self.checkSC setContentSize:CGSizeMake(123*self.listArray.count +6, 0)];
    self.checkSC.pagingEnabled = YES;
    for (int i = 0; i < self.listArray.count; i ++) {
        UIImageView *itemView = [[UIImageView alloc]initWithFrame:CGRectMake(11 +(109 +14) *i, 0, 109, self.checkSC.bounds.size.height)];
        itemView.tag = 100+i;
        [self.checkSC addSubview:itemView];
        itemView.userInteractionEnabled = YES;
        itemView.contentMode = UIViewContentModeScaleAspectFill;
        itemView.clipsToBounds = YES;
        [itemView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:self.listArray[i]]] placeholderImage:kPlaceholder];
        itemView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickImage:)];
        [itemView addGestureRecognizer:tap];
        //        UILabel *label = [[UILabel alloc]init];
//        [itemView addSubview:label];
//        BOOL hasVideo = i%2;
//        if (hasVideo == NO) {
//            [label mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.centerX.equalTo(itemView.mas_centerX);
//                make.centerY.equalTo(itemView.mas_centerY);
//                make.left.equalTo(itemView.mas_left).offset(5);
//                make.right.equalTo(itemView.mas_right).offset(5);
//            }];
//        }else{
//            [label mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.centerX.equalTo(itemView.mas_centerX);
//                make.top.equalTo(itemView.mas_top).offset(11); make.left.equalTo(itemView.mas_left).offset(5);
//                make.right.equalTo(itemView.mas_right).offset(5);
//            }];
//            UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//            [itemView addSubview:addBtn];
//            [addBtn setImage:[UIImage imageNamed:@"组4"] forState:UIControlStateNormal];
//            [addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.centerX.equalTo(itemView.mas_centerX);
//                make.top.equalTo(label.mas_bottom).offset(2);
//                make.size.mas_equalTo(CGSizeMake(21, 21));
//
//            }];
//        }
//        label.text = @"调用商家认证时后台传的图";
//        label.textColor = [UIColor hx_colorWithHexRGBAString:@"FFFFFF"];
//        label.font = [UIFont systemFontOfSize:10];
//        label.numberOfLines = 2;
     }
}

- (void)clickImage:(UITapGestureRecognizer *)tap{
    if (self.block) {
        self.block(tap.view.tag-99,self.listArray);
    }
}
@end
